package com.book.controller;

import com.book.model.dto.UniverQueryDTO;
import com.book.model.entity.University;
import com.book.service.UniversityService;
import com.book.util.BaseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学校信息 前端控制器
 * </p>
 *
 * @author auto
 * @since 2025-04-11 09:30:34
 */
@RestController
@RequestMapping("/university")
@Tag(name = "学校信息", description = "学校信息相关接口")
public class UniversityController {


    @Autowired
    private UniversityService universityService;
    @GetMapping("")
    @ApiOperation(value = "学校列表")
    public BaseResult<?> getUniversityList() {
        return BaseResult.successResult(universityService.list());
    }

    @PostMapping("/getListByPage")
    @ApiOperation(value = "学校列表")
    public BaseResult<?> getCampusListByPage(@RequestBody UniverQueryDTO dto) {
        return BaseResult.successResult(universityService.getUniversityListByPage(dto));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加学校列表")
    public BaseResult<?> getCampusListByPage(@RequestBody University dto) {
        return BaseResult.successResult(universityService.addUniversity(dto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除数据")
        public BaseResult<?> deleteUniversity(@PathVariable("id") String id) {
        return BaseResult.successResult(universityService.removeById(id));
    }

}
